/**
 *
 * 设置跨域访问
 *
 */
module.exports = function (app) {
    app.use((req, res, next) => {
        res.header('Access-Control-Allow-Credentials', true);
        res.header('Access-Control-Allow-Origin', req.headers.origin);
        res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
        res.header('Access-Control-Allow-Headers', 'X-Requested-With, X-HTTP-Method-Override, Content-Type, content-type,Accept, Api-Version');
        res.header('Access-Control-Expose-Headers', 'set-cookie');
        if(req.method === 'OPTIONS'){
            return res.ok()
        }
        next()
    })
};
